﻿using System;
using System.Collections.Generic;
using System.Text;

namespace NusyaTester {
    public class RandomList<T> : List<T>{
        private Random rnd = null;
        public new IEnumerator<T> GetEnumerator() {
            bool[] usedItems = new bool[this.Count];
            int returnedItems = 0;
            while (returnedItems < this.Count) {
                int rNum = getRandom();
                if (!usedItems[rNum]) {
                    usedItems[rNum] = true;
                    returnedItems++;
                    yield return this[rNum];
                }
            }
        }
        private int getRandom() {
            if (rnd == null) rnd = new Random();
            return rnd.Next(0, this.Count);
        }
    }
}
